package fast.loader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import fast.data.Stat;

public class ReforgeDB {
	
	public static List<Stat> REFORGABLE = Arrays.asList(Stat.spi, Stat.dodge, Stat.parry, Stat.hit, Stat.cri, Stat.hst, Stat.exp, Stat.mst);
	public static int REFORGE_CONST = 112;
	
	HashMap<Integer,Reforge> reforgeDB = new HashMap<Integer,Reforge>();
	
	public static int getReforgeId(Stat f,Stat t){
		int fi = REFORGABLE.indexOf(f);
		int ti = REFORGABLE.indexOf(t);
		if (ti < fi)
			ti++;
	    return REFORGE_CONST + (fi * 7) + ti;
	}
	
	public static Stat getReforgeFrom(int id){
	    int base = id - REFORGE_CONST - 1;
	    int from = (int) Math.floor(base / 7);
	    return REFORGABLE.get(from);
	}
	
	public static Stat getReforgeTo(int id){
		int base = id - REFORGE_CONST - 1;
		int from = (int) Math.floor(base / 7);
		int to = base % 7;
		if(from <= to)
			to++;
		return REFORGABLE.get(to);
	}
	
	public static Reforge getReforge(int id){
		return new Reforge(getReforgeFrom(id),getReforgeTo(id));
	}
}
